#include <sys/stat.h>
#include <syslog.h>
#include <fcntl.h>
#include <time.h>
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <linux/sockios.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <string.h>
#include <signal.h>
#include <stdbool.h>
#include <sys/ioctl.h>	
#include "udpbroadcast.h"
#include "serverclient.h"
#include "gate.h"

/* port we're listening on */
#define GATECTRL_PORT 3111
#define GATECTRL_BUFFER_LENGHT 100

enum ERRORS {
	GATECTRL_NOERROR,
	GATECTRL_ERR_LOGFILE,
} GATECTRL_ERRORS;

struct timespec req = { .tv_sec = 0,
						.tv_nsec = 200 };

typedef struct {
	/* Sockets */
	struct sockaddr_in serveraddr;
	struct sockaddr_in clientaddr;
	
	/* Threads */
	struct thread_data threadserver;
	struct thread_data threadclient;	
	
	/* Status variables */
	char *server_ip;
	bool master;	
	
	/* A gate driver */
	int device;
	
	
	
} gateCtrlCore;

extern int nanosleep (__const struct timespec *__requested_time,
					 struct timespec *__remaining); 
